import menu from "./menu";
/**
 * 是否有权限
 * @param {*} key
 */
export function isAuth(tableName, key) {
  let role = uni.getStorageSync("role");
  let menus = menu.list();
  for (let i = 0; i < menus.length; i++) {
    if (menus[i].roleName == role) {
      for (let j = 0; j < menus[i].backMenu.length; j++) {
        for (let k = 0; k < menus[i].backMenu[j].child.length; k++) {
          if (tableName == menus[i].backMenu[j].child[k].tableName) {
            let buttons = menus[i].backMenu[j].child[k].buttons.join(",");
            return buttons.indexOf(key) !== -1 || false;
          }
        }
      }
    }
  }
  return false;
}
